﻿@model IEnumerable<HanGu.Entity.MemberInfo>
@{
    Layout = null;
    int i = 1;
    ViewBag.ViewTitle = "客户基本信息";
    var SearchParma = ViewData["SearchParma"] as HanGu.Entity.UniversallySearchParam;
    var MemberGrade = ViewData["MemberGrade"] as SelectList;
    var Degree = ViewData["Degree"] as SelectList;
    var SexList = ViewData["SexList"] as SelectList;
    string lookup = Request["lookup"];
    string formCallback = "navTabSearch(this)";
    if (!string.IsNullOrEmpty(lookup))
    {
        formCallback = "dwzSearch(this, 'dialog')";
    }
    
}
<form id="pagerForm" method="get" action="/CustomerInfo/Default/index?action=page&OpID=@ViewData["OperateID"]">
<input type="hidden" name="pageNum" value="1" />
<input type="hidden" name="numPerPage" value="@ViewData["pageSize"]" />
<input type="hidden" name="RowCount" value="@ViewData["RowCount"]" />
<input type="hidden" name="orderField" value="${param.orderField}" />
<input type="hidden" name="Title" value="@SearchParma.Ttile" />
<input type="hidden" name="Suitabler" value="@SearchParma.Suitabler" />
<input type="hidden" name="Lectcher" value="@SearchParma.Lectcher" />
<input type="hidden" name="PalayAdress" value="@SearchParma.PalayAdress" />
<input type="hidden" name="Degree" value="@SearchParma.Degree" />
<input type="hidden" name="StarTime" value="@SearchParma.StarDateTime" />
<input type="hidden" name="EndTime" value="@SearchParma.EndDateTime" />
<input type="hidden" name="lookup" value="@lookup" />
<input type="hidden" name="IsBacklist" value="@SearchParma.IsBacklist" />
<input type="hidden" name="Sex" value="@SearchParma.Sex" />
<input type="hidden" name="Tel" value="@SearchParma.Tel" />
<input type="hidden" name="NativePlace" value="@SearchParma.NativePlace" />
<input type="hidden" name="IsMarry" value="@SearchParma.IsMarry" />
<input type="hidden" name="HasChildren" value="@SearchParma.HasChildren" />
<input type="hidden" name="Provice" value="@SearchParma.Provice" />
<input type="hidden" name="City" value="@SearchParma.City" />
<input type="hidden" name="Oganization" value="@SearchParma.Oganization" />
<input type="hidden" name="ChargeRandS" value="@SearchParma.ChargeRandS" />
<input type="hidden" name="ChargeRandE" value="@SearchParma.ChargeRandE" />
<input type="hidden" name="ContractRandS" value="@SearchParma.ContractRandS" />
<input type="hidden" name="ContractRandE" value="@SearchParma.ContractRandE" />
<input type="hidden" name="ContractNumRandS" value="@SearchParma.ContractNumRandS" />
<input type="hidden" name="ContractNumRandE" value="@SearchParma.ContractNumRandE" />
<input type="hidden" name="ImportantLevel" value="@SearchParma.ImportantLevel" />
<input type="hidden" name="AssignedIn" value="@SearchParma.AssignedIn" />
<input type="hidden" name="Groups" value="@SearchParma.Groups" />
<input type="hidden" name="IsPage" value="@SearchParma.IsPage" />
</form>
<script>
    $(function () { 
    $("#Form_@ViewData["CurrentController"] #Lectcher").val("@SearchParma.Lectcher");
    $("#Form_@ViewData["CurrentController"] #Degree").val("@SearchParma.Degree");
    });
     function SendSMS(obj) {
        $this = $(obj);
        var membersIDs = new Array();
        $.each($("input[name='MembersToSelect']:checked"), function (i, item) {
            membersIDs.push($(item).attr("value"));
        });
        if (membersIDs == null || membersIDs.length == 0) {
            alertMsg.error("未选择任何客户或所选择的客户不接收短信!");
        }
        else {
            var newUrl = $this.attr("ref");
            navTab.openTab("SendMessage", newUrl, { title: "发送短信", fresh: true, data: { membersID: membersIDs.join(","),SendingCount:membersIDs.length} });
        }
        return false;
    }
    function SendEmail(obj) {
        var emails = "";
        var membersID = "";
        var membersName = "";
        $this = $(obj);
        var membersIDs = new Array();
        $.each($("input[name='MembersToSelect']:checked"), function (i, item) {
            membersIDs.push($(item).attr("value"));
        });
        if (membersIDs == null || membersIDs.length == 0) {
            alertMsg.error("未选择任何客户或所选择的客户不接收邮件!");
        }
        else {
            var newUrl = $this.attr("ref");
            navTab.openTab("SendMessage", newUrl, { title: "发送邮件", fresh: true, data: { membersID: membersIDs.join(","),SendingCount:membersIDs.length} });
        }
        return false;
    }
    

     function MoveMember(obj)
    {
        $this=$(obj);
        var tels="";
        var membersID="";
        var membersName="";        
        $.each($("input[name='MembersToSelect']:checked"),function(i,item){
            var tmpTel=$(item).attr("value");
            if(tmpTel.length>0)
            {
                tels +=tmpTel+",";
                membersID +=$(item).attr("value")+",";
                membersName +=$(item).attr("Username")+",";
            }
        });
        tels=tels.substring(0,tels.length-1);
        membersID=membersID.substring(0,membersID.length-1);
        membersName=membersName.substring(0,membersName.length-1);
         var newUrl=$this.attr("ref");
         if(newUrl==null|| newUrl.length==0)
         {
             newUrl=$this.attr("href");
             $this.attr("ref",newUrl);
         }
         var action="";
         if(membersID==null||membersID.length==0)
         {
         action="action=view";
         }
        
         newUrl +="?emails="+escape(tels)+"&membersID="+escape(membersID)+"&membersName="+encodeURI(encodeURI(membersName))+"&"+action;
        $this.attr("href",(newUrl)); 
        return false;
    }

    function selectedCheckBox(obj)
    {   
        var checkbox=$(obj).find(':checkbox');
        var isChecked=checkbox.attr("CHECKED")=="checked";
         checkbox.attr("checked",!isChecked);       
    }

     function selectedtr(obj)
    {    alert("check")
    if(!$(obj).checked){
        $(obj).find(':parent :tr').css("selected");
        }
       return false;
    }

</script>
<div class="pageHeader">
    <form onsubmit="return @formCallback;" id="Form_@ViewData["CurrentController"]" action="/CustomerInfo/Default/index?action=search&OpID=@ViewData["OperateID"]"
    method="post">
    <input type="hidden" name="lookup" value="@lookup" />
    <div class="searchBar">
        <table class="searchContent">
            <tr>
                <td>
                    姓名：
                </td>
                <td>
                    @Html.TextBox("Title", SearchParma.Ttile)
                </td>
                <td>
                    级别：
                </td>
                <td>
                    @Html.DropDownList("Lectcher", MemberGrade, new { @class = "combox" })
                </td>
                <td>
                    手机：
                </td>
                <td>
                    @Html.TextBox("Tel", SearchParma.Tel)
                </td>
                <td>
                    <INPUT id="IsBacklist" value="true" checked="@SearchParma.IsBacklist" type="checkbox" name="IsBacklist">
                    <span>显示黑名单</span>
                </td>
            </tr>
            <tr>
                <td>
                    开通时间：
                </td>
                <td>
                    <p>
                        @Html.TextBox("StarTime", SearchParma.StarDateTime, new { @class = "date", format = "yyyy-MM-dd HH:mm", @readonly = "true" })
                    </p>
                </td>
                <td>
                    ~
                </td>
                <td>
                    <p>
                        @Html.TextBox("EndTime", SearchParma.EndDateTime, new { @class = "date", format = "yyyy-MM-dd HH:mm", @readonly = "true" })
                    </p>
                </td>
                <td>
                    学位：
                </td>
                <td>
                    @Html.DropDownList("Degree", Degree, new { @class = "combox" })
                </td>
                <td align="right">
                    <div class="subBar">
                        <ul>
                            <li>
                                <div class="buttonActive">
                                    <div class="buttonContent">
                                        <button type="submit" name="submit">
                                            检索</button></div>
                                </div>
                            </li>
                            <li><a class="button" href="/CustomerInfo/Default/HighSeach" height="400" target="dialog"
                                mask="true" title="查询框"><span>高级检索</span></a></li>
                        </ul>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    </form>
</div>
<div class="pageContent">
    @Html.Partial("Buttons")
    <table class="table" width="100%" layouth="170">
        <thead>
            <tr class="header">
                <th>
                    序号
                </th>
                <th>
                    姓名
                </th>
                <th>
                    性别
                </th>
                <th>
                    学位
                </th>
                <th>
                    级别
                </th>
                <th>
                    积分
                </th>
                <th>
                    电话
                </th>
                <th>
                    注册时间
                </th>
                <th>
                    归属用户
                </th>
                <th>
                    <input type="checkbox" class="checkboxCtrl" group="MembersToSelect" />全选
                </th>
            </tr>
        </thead>
        @foreach (var item in Model)
        {            
            <tr id="memberItem" target="CustomerInfo_id" rel="@item.ID/@item.GUID" itemID="@item.ID" nosms="@item.NoSMS" noemail="@item.NoEmail" tel="@item.Tel" email="@item.Email" style="@(item.IsNew ? "color:Red" : string.Empty)" onclick="selectedCheckBox(this)">
                <td>
                    @i
                </td>
                <td>
                    @item.RealName
                </td>
                <td>
                    @{
            var modelsex = SexList.SingleOrDefault(c => c.Value == item.Sex);
            if (modelsex != null)
            {
                        @modelsex.Text
            }
                    }
                </td>
                <td>
                    @{
            var modelDegree = Degree.SingleOrDefault(c => c.Value == item.Degree);
            if (modelDegree != null)
            {
                        @modelDegree.Text
            }   
                    }
                </td>
                <td>
                    @{
            var modelGrade = MemberGrade.SingleOrDefault(c => c.Value == item.Grade);
            if (modelGrade != null)
            { 
                        @modelGrade.Text;
            }
                    }
                </td>
                <td>
                    @item.Charge
                </td>
                <td>
                    @item.Tel
                </td>
                <td>
                    <span formatdate="yyyy-MM-dd HH:mm">
                        @item.CreateTime</span>
                </td>
                <td>
                    @{
            var managers = string.Join(" ", item.MemberAssignedManagers.Select(c => c.RealName + c.User));
                        @managers            
                    }
                </td>
                <td>
                    <input  type="checkbox" id="MembersToSelect" name="MembersToSelect" tel='@(item.NoSMS ? item.Tel : string.Empty)'  email="@(item.NoEmail ? item.Email : string.Empty)" value="@item.ID" Username='@item.UserName' disabled=disabled />
                </td>
            </tr>
            i += 1;
        }
    </table>
</div>
<div class="panelBar">
    <div class="pages">
        <span>共【@ViewData["RowCount"] 】条,每页显示【@ViewData["pageSize"] 】条</span>
    </div>
    <div class="pagination" targettype="navTab" totalcount="@ViewData["RowCount"] "
            numperpage="@ViewData["pageSize"] " pagenumshown="10" currentpage="@Request["pageNum"] ">
    </div>
</div>
